﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WuDada.Core.Post.Domain;
using WuDada.Core.Post.Persistence;

namespace WuDada.Core.Post.Service.Impl
{
    public class SignUpService : ISignUpService
    {
        public ISignUpDao SignUpDao { get; set; }

        /// <summary>
        /// 新增SignUp
        /// </summary>
        /// <param name="signUpVO">被新增的SignUp</param>
        /// <returns>新增後的SignUp</returns>
        public SignUpVO CreateSignUp(SignUpVO signUpVO)
        {
            return SignUpDao.CreateSignUp(signUpVO);
        }

        /// <summary>
        /// 取得SignUp By SignUpId
        /// </summary>
        /// <param name="signUpId">SignUpId</param>
        /// <returns>SignUp</returns>
        public SignUpVO GetSignUpById(int signUpId)
        {
            return SignUpDao.GetSignUpById(signUpId);
        }

        /// <summary>
        /// 取得SignUp By PostId
        /// </summary>
        /// <param name="postId">PostId</param>        
        /// <returns>SignUp清單</returns>
        public IList<SignUpVO> GetSignUpListByPostId(int postId)
        {
            return SignUpDao.GetSignUpListByPostId(postId);
        }

        /// <summary>
        /// 刪除SignUp
        /// </summary>
        /// <param name="signUpVO">被刪除的SignUp</param>
        public void DeleteSignUp(SignUpVO signUpVO)
        {
            SignUpDao.DeleteSignUp(signUpVO);
        }

        /// <summary>
        /// 更新SignUp
        /// </summary>
        /// <param name="signUpVO">被更新的SignUp</param>
        /// <returns>更新後的SignUp</returns>
        public SignUpVO UpdateSignUp(SignUpVO signUpVO)
        {
            return SignUpDao.UpdateSignUp(signUpVO);
        }

        /// <summary>
        /// 取得SignUp By PostId
        /// </summary>
        /// <param name="postId">PostId</param>
        /// <param name="sortField">排序欄位</param>
        /// <param name="sortDesc">升降冪排序</param>
        /// <returns>SignUp清單</returns>
        public IList<SignUpVO> GetSignUpListByPostId(int postId, string sortField, bool sortDesc)
        {
            return SignUpDao.GetSignUpListByPostId(postId, sortField, sortDesc);
        }

        /// <summary>
        /// 取得SignUp By PostId
        /// </summary>
        /// <param name="postId">PostId</param>
        /// <param name="pageIndex">分頁索引</param>
        /// <param name="pageSize">分頁大小</param>
        /// <param name="sortField">排序欄位</param>
        /// <param name="sortDesc">升降冪排序</param>
        /// <returns>SignUp清單</returns>
        public IList<SignUpVO> GetSignUpListByPostId(int postId, int pageIndex, int pageSize, string sortField, bool sortDesc)
        {
            return SignUpDao.GetSignUpListByPostId(postId, pageIndex, pageSize, sortField, sortDesc);
        }

        /// <summary>
        /// 取得SignUp筆數 By PostId
        /// </summary>
        /// <param name="postId">PostId</param>
        /// <returns>SignUp清單</returns>
        public int CountSignUpListByPostId(int postId)
        {
            return SignUpDao.CountSignUpListByPostId(postId);
        }

        /// <summary>
        /// 確認是否已經有報名
        /// </summary>
        /// <param name="postId">PostId</param>
        /// <param name="email">Email</param>
        /// <returns>是否已經有報名</returns>
        public bool GetSignUpByPostIdAndEmail(int postId, string email)
        {
            return SignUpDao.GetSignUpByPostIdAndEmail(postId, email);
        }

        /// <summary>
        /// 動態查詢筆數SignUp
        /// </summary>
        /// <param name="where">搜尋語法，用Where...order by ...</param>
        /// <returns>筆數</returns>
        public int CountSignUpByWhere(string where)
        {
            return SignUpDao.CountSignUpByWhere(where);
        }

        /// <summary>
        /// 動態查詢SignUp
        /// </summary>
        /// <param name="where">搜尋語法，用Where...order by ...</param>
        /// <param name="pageIndex">分頁索引</param>
        /// <param name="pageSize">分頁大小</param>
        /// <returns>搜尋結果</returns>
        public IList<SignUpVO> SearchSignUpByWhere(string where, int pageIndex, int pageSize)
        {
            return SignUpDao.SearchSignUpByWhere(where, pageIndex, pageSize);
        }
    }
}
